home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / menus / envmnu11.zip / ATTRMENU.BAT next >
DOS Batch File  |  1992-11-16  |  3KB  |  118 lines

  1. @echo off
  2. REM EnviMenu utility to alter attributes on a file
  3.  
  4. REM CHECK INPUT
  5. if a%1z==az GOTO ATTRMENU_HELP
  6. if NOT a%3z==az GOTO ATTRMENU_HELP
  7. if a%2z==az GOTO ALLFILES
  8. if %1==/? GOTO ATTRMENU_HELP
  9. if %1==/H GOTO ATTRMENU_HELP
  10. if %1==/HELP GOTO ATTRMENU_HELP
  11. if %1==/h GOTO ATTRMENU_HELP
  12. if %1==/help GOTO ATTRMENU_HELP
  13. set INPUT_FILESPEC=%1
  14. set INPUT_ATTR=%2
  15. GOTO PARSE_ATTR
  16.  
  17. :ALLFILES
  18. set INPUT_FILESPEC=*.*
  19. set INPUT_ATTR=%1
  20. GOTO PARSE_ATTR
  21.  
  22. :PARSE_ATTR
  23. if %INPUT_ATTR%==+a GOTO PLUSA
  24. if %INPUT_ATTR%==+A GOTO PLUSA
  25. if %INPUT_ATTR%==-a GOTO MINUSA
  26. if %INPUT_ATTR%==-A GOTO MINUSA
  27. if %INPUT_ATTR%==+r GOTO PLUSR
  28. if %INPUT_ATTR%==+R GOTO PLUSR
  29. if %INPUT_ATTR%==-r GOTO MINUSR
  30. if %INPUT_ATTR%==-R GOTO MINUSR
  31. if %INPUT_ATTR%==+s GOTO PLUSS
  32. if %INPUT_ATTR%==+S GOTO PLUSS
  33. if %INPUT_ATTR%==-s GOTO MINUSS
  34. if %INPUT_ATTR%==-S GOTO MINUSS
  35. if %INPUT_ATTR%==+h GOTO PLUSH
  36. if %INPUT_ATTR%==+H GOTO PLUSH
  37. if %INPUT_ATTR%==-h GOTO MINUSH
  38. if %INPUT_ATTR%==-H GOTO MINUSH
  39. echo DO NOT RECOGNIZE ATTRIBUTE; MUST BE +A, -A, +R, -R, +S, -S, +H, or -H
  40. pause
  41. GOTO FINISHED
  42.  
  43. :PLUSA
  44. set ATTR_LTTR=a
  45. GOTO PLUS
  46. :MINUSA
  47. set ATTR_LTTR=a
  48. GOTO MINUS
  49. :PLUSR
  50. set ATTR_LTTR=r
  51. GOTO PLUS
  52. :MINUSR
  53. set ATTR_LTTR=r
  54. GOTO MINUS
  55. :PLUSS
  56. set ATTR_LTTR=s
  57. GOTO PLUS
  58. :MINUSS
  59. set ATTR_LTTR=s
  60. GOTO MINUS
  61. :PLUSH
  62. set ATTR_LTTR=h
  63. GOTO PLUS
  64. :MINUSH
  65. set ATTR_LTTR=h
  66. GOTO MINUS
  67.  
  68. :PLUS
  69. set FIND_ATTR=-
  70. set SET_ATTR=+
  71. GOTO LOOPY
  72. :MINUS
  73. set FIND_ATTR=
  74. set SET_ATTR=-
  75. GOTO LOOPY
  76.  
  77.  
  78. REM   FINALLY, THIS IS THE MAIN LOOP
  79. set FILECHOICE=
  80. :LOOPY
  81. dir /A-d%FIND_ATTR%%ATTR_LTTR% %INPUT_FILESPEC% /b > FileList.tmp
  82. envimenu FILECHOICE FileList.tmp /Esc /Sort /Prompt "Select file for attribute change (Esc for none)"
  83. if ERRORLEVEL 1 GOTO FINISHED
  84. del FileList.tmp
  85. if %FILECHOICE%==FILELIST.TMP GOTO LOOPY
  86. attrib %SET_ATTR%%ATTR_LTTR% %FILECHOICE%
  87. GOTO LOOPY
  88.  
  89. :ATTRMENU_HELP
  90. echo 
  91. echo Use the AttrMenu command to interactively display or change a file attribute.
  92. echo  
  93. echo SYNTAX:  AttrMenu [filename] (+ or -)(R or A or S orH)
  94. echo Where:
  95. echo   [filename]      Specifies the file you want to change in current directory
  96. echo   +               Sets an attribute.
  97. echo   -               Cancels an attribute.
  98. echo   R               Sets the read-only attribute.
  99. echo   A               Sets the archive file attribute.
  100. echo   S               Sets the system file attribute.
  101. echo   H               Sets the hidden file attribute.
  102. echo  
  103. echo EXAMPLE: To Selectively set Read-only attribute in this directory
  104. echo     ATTRMENU *.* +r   or  ATTRMENU +r
  105. echo  
  106. pause
  107. GOTO FINISHED
  108.  
  109. :FINISHED
  110. if exist FileList.tmp del FileList.tmp
  111. set INPUT_FILESPEC=
  112. set INPUT_ATTR=
  113. set ATTR_LTTR=
  114. set FIND_ATTR=
  115. set SET_ATTR=
  116. set FILECHOICE=
  117. cls
  118.